package top.marken.onlineclass.util;

public class JsonData {
    /**
     * 处理成功状态码
     */
    public static final int CODE_SUCCESS = 0;
    /**
     * 正在处理中状态码
     */
    public static final int CODE_PROCESS = 1;
    /**
     * 处理失败状态码
     */
    public static final int CODE_FAIL = -1;
    /**
     * 处理任务时出现错误状态码
     */
    public static final int CODE_ERROR = -2;

    private int code = CODE_SUCCESS;
    private Object data;
    private String msg;

    public JsonData() {}
    public JsonData(int code, Object data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }

    public static JsonData buildSuccess(Object data) {
        return new JsonData(CODE_SUCCESS,data,"处理成功！");
    }

    public static JsonData buildSuccess(Object data, String msg) {
        return new JsonData(CODE_SUCCESS,data,msg);
    }

    public static JsonData buildError(Object data) {
        return new JsonData(CODE_ERROR,data,"处理出现错误！");
    }

    public static JsonData buildError(Object data, String msg) {
        return new JsonData(CODE_ERROR,data,msg);
    }

    public static JsonData buildFail(Object data) {
        return new JsonData(CODE_FAIL,data,"处理失败！");
    }

    public static JsonData buildFail(Object data, String msg) {
        return new JsonData(CODE_FAIL,data,msg);
    }

    public static int getCodeSuccess() {
        return CODE_SUCCESS;
    }

    public static int getCodeProcess() {
        return CODE_PROCESS;
    }

    public static int getCodeFail() {
        return CODE_FAIL;
    }

    public static int getCodeError() {
        return CODE_ERROR;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
